/*
 * Copyright 2009 Original Author(s)
 * 
 * This file is part of Kommando
 * 
 * Kommando is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Kommando is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Kommando.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.kommando.core;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Window;

import javax.swing.Icon;
import javax.swing.text.JTextComponent;

import org.kommando.core.search.Result;

/**
 * Skinnable part of the ui.
 * 
 * @author Peter De Bruycker
 */
public interface KommandoWindow {

    public static enum Selector {
        DIRECT, ACTION, INDIRECT;
    }

    /**
     * Show this {@link KommandoWindow}
     */
    void show();

    boolean isVisible();

    /**
     * Hide this {@link KommandoWindow}
     */
    void hide();

    /**
     * This method must show the given result in the ui at the correct selector. The result can be <code>null</code>.
     * <p>
     * The {@link Icon} of the result will have the size returned by the {@link #getIconSize()} method.
     * 
     * @param selection
     *            the selection to show, can be <code>null</code>
     * 
     * @see #getIconSize()
     */
    void setSelection(Selector selector, Result<?> selection);

    void setActiveSelector(Selector selector);

    /**
     * Show the indirect object part of this {@link KommandoWindow}
     */
    void expand();

    /**
     * Hide the indirect object part of this {@link KommandoWindow}
     */
    void shrink();

    /**
     * Dispose. Can be used to perform cleanup of resources (graphics, ...)
     */
    void dispose();

    /**
     * Return the icon size used by this {@link KommandoWindow}. All {@link Displayable}s passed to the respective
     * methods will have icons of this size.
     * 
     * @return the icon size
     */
    Dimension getIconSize();

    Point getSelectionListPopupPosition(Selector selector);

    /**
     * Returns the {@link Window} used internally by this {@link KommandoWindow}
     * 
     * @return the {@link Window}
     */
    Window getWindowControl();

    /**
     * Sets the given {@link Selector} in text mode.
     * 
     * @param selector
     *            the selector, either {@link Selector#DIRECT} or {@link Selector#INDIRECT}
     * @param inTextMode
     *            text mode
     */
    void setInTextMode(Selector selector, boolean inTextMode);

    /**
     * Sets the text component for the given {@link Selector}. This component should be shown to the user when he
     * switches to text mode.
     * 
     * @param selector
     *            the selector, either {@link Selector#DIRECT} or {@link Selector#INDIRECT}
     * @param textComponent
     *            the text component
     */
    void setTextComponent(Selector selector, JTextComponent textComponent);
}
